package file;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

import org.junit.Test;

public class FilesDemo {
	
	@Test
	public void test() throws IOException {
		// 1.文件拷贝 (srcPath,destPatn, 拷贝Options)
		Files.copy(Paths.get("a.txt"), Paths.get("b.txt"), StandardCopyOption.REPLACE_EXISTING);
		
		// 2.创建普通文件
		// Files.createFile(Paths.get("c.txt"));
		
		// 3.创建目录
		// Files.createDirectories(Paths.get("abc"));
		
		// 4.the file size, in bytes 返回字节, UTF-8字符编码一个中文1,2,3 GBK一个中文2个
		long size = Files.size(Paths.get("a.txt"));
		System.out.println(size);
		
		// 5.删除文件
		Files.delete(Paths.get("a.txt"));
	}
}
